﻿<%@ Page Title="" Language="C#" MasterPageFile="~/master.master" %>

<script runat="server">
    [System.Web.Services.WebMethod]
    public static bool ValidateUser(string name, string password)
    {
        if (Membership.ValidateUser(name, password))
        {
            FormsAuthentication.SetAuthCookie("admin", false);
            return true;
        }

        return false;
    }

    [System.Web.Services.WebMethod]
    public static void LogOff()
    {
        FormsAuthentication.SignOut();
    }
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="pagetitle" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="pagemaincontent" runat="Server">
    UserName:
    <input id="name" /><br />
    Password:<input id="password" type="password" />
    <br />
    <input type="button" value="Login" onclick="login()" />
    <input type="button" value="Logoff" onclick="logoff()" />
    <script type="text/javascript" src="jQueryClient/postback.js"></script>
    <script type="text/javascript">
        function login() {
            $.doPostback("ValidateUser", { name: $("#name").val(), password: $("#password").val() }, function (data) {
                if (data.d)
                    location = "Admin/Default.aspx";
            });
        }

        function logoff() {
            $.doPostback("LogOff", {}, function (data) {
            });
        }
    </script>
</asp:Content>
